#include "mainwindow.h"
#include "ui_mainwindow.h"
#include"configwin.h"
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::setName(QString name)
{
    ui->userLAbel->setText(name);
}


void MainWindow::on_exitButton_clicked()
{
    this->close();
}

void MainWindow::on_configButton_clicked()
{
    configWin=new ConfigWin;
    connect(configWin, &ConfigWin::sendData, this, &MainWindow::recvData);//两个窗体通信
    configWin->show();
    this->hide();
}

void MainWindow::recvData(QString data){//收到ConfigWin的sendData()信号，设置本ui的文本，显示本ui
    ui->lightLabel->setText(data);
    this->show();
    disconnect(configWin, &ConfigWin::sendData, this, &MainWindow::recvData);
}
